//package com.plian.system.service.transfer.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.plian.Tools.*;
//import com.plian.Tools.file.FilesUtil;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.constant.sys.FormStatusConstant;
//import com.plian.system.constant.sys.FormTypeConstant;
//import com.plian.system.dao.sys.file.FileDao;
//import com.plian.system.dto.qg.subsidiary.ReformTransferFileDTO;
//import com.plian.system.entity.pm.property.PropertyBasics;
//import com.plian.system.entity.qg.subsidiary.MixedOwnershipStructure;
//import com.plian.system.entity.qg.subsidiary.SubsidiaryMixedReform;
//import com.plian.system.enumeratea.ReformStatus;
//import com.plian.system.service.pm.property.IPropertyBasicsService;
//import com.plian.system.service.qg.subsidiary.IMixedOwnershipStructureService;
//import com.plian.system.service.qg.subsidiary.ISubsidiaryMixedReformChangeService;
//import com.plian.system.service.qg.subsidiary.ISubsidiaryMixedReformOutService;
//import com.plian.system.service.qg.subsidiary.ISubsidiaryMixedReformService;
//import com.plian.system.service.sys.code.IFormCodeService;
//import com.plian.system.service.sys.file.FileService;
//import com.plian.system.service.transfer.ISubsidiaryMixedReformTransferService;
//import com.plian.system.service.transfer.ITransferFlowService;
//import com.plian.system.vo.qg.subsidiary.SubsidiaryMixedReformVO;
//import com.plian.system.wrapper.qg.subsidiary.SubsidiaryMixedReformWrapper;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//import static com.plian.system.constant.sys.FormStatusConstant.*;
//
//@Slf4j
//@Service
//@AllArgsConstructor
//public class SubsidiaryMixedReformTransferServiceImpl implements ISubsidiaryMixedReformTransferService {
//
//    private ISubsidiaryMixedReformService subsidiaryMixedReformService;
//
//    private IPropertyBasicsService propertyBasicsService;
//
//    private SubsidiaryMixedReformWrapper subsidiaryMixedReformWrapper;
//
//    private IFormCodeService formCodeService;
//
//    private IMixedOwnershipStructureService mixedOwnershipStructureService;
//
//    private ITransferFlowService transferFlowService;
//
//    private ISubsidiaryMixedReformChangeService subsidiaryMixedReformChangeService;
//
//    private ISubsidiaryMixedReformOutService subsidiaryMixedReformOutService;
//
//    private FileDao fileDao;
//
//    private FileService fileService;
//
//    @Override
//    public String checkRegisterList(List<SubsidiaryMixedReformVO> subsidiaryMixedReformVOList) {
//        String tokenOrgId = TokenUtil.getTokenOrgId();
//        String tokenUserId = TokenUtil.getTokenUserId();
//
//        PropertyBasics parentProperty = propertyBasicsService.getOne(Wrappers.<PropertyBasics>query()
//                .lambda().eq(PropertyBasics::getOrgId, tokenOrgId));
//        if (parentProperty == null){
//            return  "该账号所属单位对应产权数据未配置!";
//        }
//        //产权子节点
//        List<PropertyBasics> allChildProperty = propertyBasicsService.list(Wrappers.<PropertyBasics>query()
//                .lambda().eq(PropertyBasics::getStatus, FormStatusConstant.FINISH)
//                .likeRight(PropertyBasics::getPropertyCode, parentProperty.getPropertyCode()));
//        Map<String, PropertyBasics> childPropertyMap = allChildProperty.stream()
//                .filter(propertyBasics -> StringUtil.isNotBlank(propertyBasics.getOrgCode()))
//                .collect(Collectors.toMap(PropertyBasics::getOrgCode, propertyBasics -> propertyBasics));
//        //登记数据
//        List<SubsidiaryMixedReform> subsidiaryMixedReformList = subsidiaryMixedReformService.list(Wrappers.<SubsidiaryMixedReform>query()
//                .lambda().eq(SubsidiaryMixedReform::getFormType, FormTypeConstant.QG_SUBSIDIARY_FORM));
//        Map<String, SubsidiaryMixedReform> subsidiaryMixedReformMap = subsidiaryMixedReformList.stream()
//                .collect(Collectors.toMap(SubsidiaryMixedReform::getMixedEnterpriseId, subsidiaryMixedReform -> subsidiaryMixedReform));
//
//        List<String> messages = new ArrayList<>();
//        for (SubsidiaryMixedReformVO subsidiaryMixedReformVO : subsidiaryMixedReformVOList){
//            if (!childPropertyMap.containsKey(subsidiaryMixedReformVO.getAicOrgCode())){
//                messages.add("aicOrgCode = " + subsidiaryMixedReformVO.getAicOrgCode() + "，产权未登记");
//                continue;
//            }
//
//            PropertyBasics propertyBasics = childPropertyMap.get(subsidiaryMixedReformVO.getAicOrgCode());
//            String propertyId = propertyBasics.getId();
//            if (subsidiaryMixedReformMap.containsKey(propertyId)){
//                SubsidiaryMixedReform subsidiaryMixedReform = subsidiaryMixedReformMap.get(propertyId);
//                int status = subsidiaryMixedReform.getStatus();
//                if (status != UNREVIEWED && status != REJECT && status != STASH){
//                    messages.add("aicOrgCode = " + subsidiaryMixedReformVO.getAicOrgCode() + " 该数据审批中或已审核,");
//                    continue;
//                }
//                subsidiaryMixedReformVO.setId(subsidiaryMixedReform.getId());
//                subsidiaryMixedReformVO.setCode(subsidiaryMixedReform.getCode());
//            }
//            subsidiaryMixedReformVO.setDataSource(tokenUserId);
//            subsidiaryMixedReformVO.setMixedEnterpriseId(propertyId);
//            subsidiaryMixedReformVO.setUnitRankId(propertyBasics.getOrgGradation());
//            subsidiaryMixedReformVO.setMajorIndustryId(propertyBasics.getMajorIndustries());
//            subsidiaryMixedReformVO.setAffiliatedOrgFullName(propertyBasics.getAffiliatedOrgFullName());
//            subsidiaryMixedReformVO.setFunctionalCategoryId(propertyBasics.getFunctionalCategoryName());
//            subsidiaryMixedReformVO.setMixedCategoryId(propertyBasics.getOrgCategory());
//            subsidiaryMixedReformVO.setStateFundedRelation(propertyBasics.getStateFundedRelation());
//            subsidiaryMixedReformVO.setRegisteredCapital(BigDecimalUtil.toBigdecimal(propertyBasics.getRegCapital()));
//        }
//
//        if (CollectionUtil.isNotEmpty(messages)){
//            return messages.stream().collect(Collectors.joining(StringPool.COMMA));
//        }
//        return null;
//    }
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean saveRegisterList(List<SubsidiaryMixedReformVO> subsidiaryMixedReformVOList) {
//        List<String> submitIds = new ArrayList<>();
//        for (SubsidiaryMixedReformVO subsidiaryMixedReformVO : subsidiaryMixedReformVOList){
//            subsidiaryMixedReformVO.setFormType(String.valueOf(FormTypeConstant.QG_SUBSIDIARY_FORM));
//            subsidiaryMixedReformVO.setVersion(1);
//            subsidiaryMixedReformVO.setIsLatest(2);
//            subsidiaryMixedReformVO.setStatus(FormStatusConstant.UNREVIEWED);
//            if (subsidiaryMixedReformVO.getId() == null){
//                subsidiaryMixedReformVO.setCode(formCodeService.getCode(FormTypeConstant.QG_SUBSIDIARY_FORM));
//            }
//            SubsidiaryMixedReform subsidiaryMixedReform = subsidiaryMixedReformWrapper.voToEntity(subsidiaryMixedReformVO);
//            subsidiaryMixedReformService.saveOrUpdate(subsidiaryMixedReform);
//            submitIds.add(String.valueOf(subsidiaryMixedReform.getId()));
//            mixedOwnershipStructureService.remove(Wrappers.<MixedOwnershipStructure>query()
//                    .lambda().eq(MixedOwnershipStructure::getMixedReformId, subsidiaryMixedReform.getId()));
//            if (CollectionUtil.isNotEmpty(subsidiaryMixedReform.getMixedOwnershipStructures())){
//                for (MixedOwnershipStructure mixedOwnershipStructure : subsidiaryMixedReform.getMixedOwnershipStructures()){
//                    mixedOwnershipStructure.setMixedReformId(subsidiaryMixedReform.getId());
//                }
//                mixedOwnershipStructureService.saveList(subsidiaryMixedReform.getMixedOwnershipStructures());
//            }
//        }
//        transferFlowService.submit(submitIds, FormTypeConstant.QG_SUBSIDIARY_FORM);
//        return true;
//    }
//
//    @Override
//    public String checkChangeList(List<SubsidiaryMixedReformVO> subsidiaryMixedReformVOList) {
//        String tokenOrgId = TokenUtil.getTokenOrgId();
//        String tokenUserId = TokenUtil.getTokenUserId();
//
//        PropertyBasics parentProperty = propertyBasicsService.getOne(Wrappers.<PropertyBasics>query()
//                .lambda().eq(PropertyBasics::getOrgId, tokenOrgId));
//        if (parentProperty == null){
//            return  "该账号所属单位对应产权数据未配置!";
//        }
//        //产权子节点
//        List<PropertyBasics> allChildProperty = propertyBasicsService.list(Wrappers.<PropertyBasics>query()
//                .lambda().eq(PropertyBasics::getStatus, FormStatusConstant.FINISH)
//                .likeRight(PropertyBasics::getPropertyCode, parentProperty.getPropertyCode()));
//        Map<String, PropertyBasics> childPropertyMap = allChildProperty.stream()
//                .filter(propertyBasics -> StringUtil.isNotBlank(propertyBasics.getOrgCode()))
//                .collect(Collectors.toMap(PropertyBasics::getOrgCode, propertyBasics -> propertyBasics));
//        //可进行变更操作的混改记录
//        List<SubsidiaryMixedReform> subsidiaryMixedReformList = subsidiaryMixedReformService.list(Wrappers.<SubsidiaryMixedReform>query()
//                .lambda().eq(SubsidiaryMixedReform::getIsLatest, 2)
//                .eq(SubsidiaryMixedReform::getReformStatus, ReformStatus.ADJUSTABLE.getStatus()));
//        Map<String, SubsidiaryMixedReform> subsidiaryMixedReformMap = subsidiaryMixedReformList.stream()
//                .collect(Collectors.toMap(SubsidiaryMixedReform::getMixedEnterpriseId, subsidiaryMixedReform -> subsidiaryMixedReform));
//        //传输过来的单据数据
//        List<SubsidiaryMixedReform> transferReformList = subsidiaryMixedReformService.list(Wrappers.<SubsidiaryMixedReform>query()
//                .lambda().eq(SubsidiaryMixedReform::getDataSource, tokenUserId)
//                .eq(SubsidiaryMixedReform::getStatus, FormTypeConstant.QG_SUBSIDIARY_CHANGE_FORM));
//        Map<String, SubsidiaryMixedReform> transferReformMap = transferReformList.stream()
//                .collect(Collectors.toMap(SubsidiaryMixedReform::getDataSourceId, subsidiaryMixedReform -> subsidiaryMixedReform));
//
//
//        List<String> messages = new ArrayList<>();
//        for (SubsidiaryMixedReformVO subsidiaryMixedReformVO : subsidiaryMixedReformVOList){
//            if (!childPropertyMap.containsKey(subsidiaryMixedReformVO.getAicOrgCode())){
//                messages.add("aicOrgCode = " + subsidiaryMixedReformVO.getAicOrgCode() + "，产权未登记");
//                continue;
//            }
//
//            PropertyBasics propertyBasics = childPropertyMap.get(subsidiaryMixedReformVO.getAicOrgCode());
//            String propertyId = propertyBasics.getId();
//            if(transferReformMap.containsKey(subsidiaryMixedReformVO.getDataSourceId())){
//                SubsidiaryMixedReform oldTransferReform = transferReformMap.get(subsidiaryMixedReformVO.getDataSourceId());
//                if (oldTransferReform.getStatus() != UNREVIEWED && oldTransferReform.getStatus() != REJECT && oldTransferReform.getStatus() != STASH){
//                    messages.add("aicOrgCode = " + subsidiaryMixedReformVO.getAicOrgCode()
//                            + ", dataSourceId = " + subsidiaryMixedReformVO.getDataSourceId() + "，再审批流程中或已审核");
//                    continue;
//                }
//                subsidiaryMixedReformVO.setId(oldTransferReform.getId());
//                subsidiaryMixedReformVO.setInitialId(oldTransferReform.getInitialId());
//                subsidiaryMixedReformVO.setLastVersionId(oldTransferReform.getLastVersionId());
//                subsidiaryMixedReformVO.setVersion(oldTransferReform.getVersion());
//            }else {
//                if (subsidiaryMixedReformMap.containsKey(propertyId)){
//                    SubsidiaryMixedReform subsidiaryMixedReform = subsidiaryMixedReformMap.get(propertyId);
//                    subsidiaryMixedReformVO.setInitialId(subsidiaryMixedReform.getInitialId());
//                    subsidiaryMixedReformVO.setLastVersionId(subsidiaryMixedReform.getId());
//                    subsidiaryMixedReformVO.setVersion(subsidiaryMixedReform.getVersion() + 1);
//                }else {
//                    messages.add("aicOrgCode = " + subsidiaryMixedReformVO.getAicOrgCode()
//                            + ", dataSourceId = " + subsidiaryMixedReformVO.getDataSourceId() + "，不能进行混改变更");
//                    continue;
//                }
//            }
//
//            subsidiaryMixedReformVO.setDataSource(tokenUserId);
//            subsidiaryMixedReformVO.setMixedEnterpriseId(propertyId);
//            subsidiaryMixedReformVO.setUnitRankId(propertyBasics.getOrgGradation());
//            subsidiaryMixedReformVO.setMajorIndustryId(propertyBasics.getMajorIndustries());
//            subsidiaryMixedReformVO.setAffiliatedOrgFullName(propertyBasics.getAffiliatedOrgFullName());
//            subsidiaryMixedReformVO.setFunctionalCategoryId(propertyBasics.getFunctionalCategoryName());
//            subsidiaryMixedReformVO.setMixedCategoryId(propertyBasics.getOrgCategory());
//            subsidiaryMixedReformVO.setStateFundedRelation(propertyBasics.getStateFundedRelation());
//            subsidiaryMixedReformVO.setRegisteredCapital(BigDecimalUtil.toBigdecimal(propertyBasics.getRegCapital()));
//        }
//
//        if (CollectionUtil.isNotEmpty(messages)){
//            return messages.stream().collect(Collectors.joining(StringPool.COMMA));
//        }
//        return null;
//    }
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean saveChangeList(List<SubsidiaryMixedReformVO> subsidiaryMixedReformVOList) {
//        List<String> submitIds = new ArrayList<>();
//        for (SubsidiaryMixedReformVO subsidiaryMixedReformVO : subsidiaryMixedReformVOList){
//            subsidiaryMixedReformVO.setFormType(String.valueOf(FormTypeConstant.QG_SUBSIDIARY_CHANGE_FORM));
//            subsidiaryMixedReformVO.setStatus(FormStatusConstant.UNREVIEWED);
//            if (subsidiaryMixedReformVO.getId() == null){
//                subsidiaryMixedReformVO.setCode(formCodeService.getCode(FormTypeConstant.QG_SUBSIDIARY_CHANGE_FORM));
//            }
//            SubsidiaryMixedReform subsidiaryMixedReform = subsidiaryMixedReformWrapper.voToEntity(subsidiaryMixedReformVO);
//            subsidiaryMixedReformChangeService.saveOrUpdate(subsidiaryMixedReform);
//            submitIds.add(String.valueOf(subsidiaryMixedReform.getId()));
//            mixedOwnershipStructureService.remove(Wrappers.<MixedOwnershipStructure>query()
//                    .lambda().eq(MixedOwnershipStructure::getMixedReformId, subsidiaryMixedReform.getId()));
//            if (CollectionUtil.isNotEmpty(subsidiaryMixedReform.getMixedOwnershipStructures())){
//                for (MixedOwnershipStructure mixedOwnershipStructure : subsidiaryMixedReform.getMixedOwnershipStructures()){
//                    mixedOwnershipStructure.setMixedReformId(subsidiaryMixedReform.getId());
//                }
//                mixedOwnershipStructureService.saveList(subsidiaryMixedReform.getMixedOwnershipStructures());
//            }
//        }
//        transferFlowService.submit(submitIds, FormTypeConstant.QG_SUBSIDIARY_CHANGE_FORM);
//        return true;
//    }
//
//    @Override
//    public String checkOutList(List<SubsidiaryMixedReformVO> subsidiaryMixedReformVOList) {
//        String tokenOrgId = TokenUtil.getTokenOrgId();
//        String tokenUserId = TokenUtil.getTokenUserId();
//
//        PropertyBasics parentProperty = propertyBasicsService.getOne(Wrappers.<PropertyBasics>query()
//                .lambda().eq(PropertyBasics::getOrgId, tokenOrgId));
//        if (parentProperty == null){
//            return  "该账号所属单位对应产权数据未配置!";
//        }
//        //产权子节点
//        List<PropertyBasics> allChildProperty = propertyBasicsService.list(Wrappers.<PropertyBasics>query()
//                .lambda().eq(PropertyBasics::getStatus, FormStatusConstant.FINISH)
//                .likeRight(PropertyBasics::getPropertyCode, parentProperty.getPropertyCode()));
//        Map<String, PropertyBasics> childPropertyMap = allChildProperty.stream()
//                .filter(propertyBasics -> StringUtil.isNotBlank(propertyBasics.getOrgCode()))
//                .collect(Collectors.toMap(PropertyBasics::getOrgCode, propertyBasics -> propertyBasics));
//        List<String> propertyIdList = allChildProperty.stream().map(PropertyBasics::getId).collect(Collectors.toList());
//        //可进行变更操作的混改记录
//        List<SubsidiaryMixedReform> subsidiaryMixedReformList = subsidiaryMixedReformService.list(Wrappers.<SubsidiaryMixedReform>query()
//                .lambda().eq(SubsidiaryMixedReform::getIsLatest, 2)
//                .eq(SubsidiaryMixedReform::getReformStatus, ReformStatus.ADJUSTABLE.getStatus()));
//        Map<String, SubsidiaryMixedReform> subsidiaryMixedReformMap = subsidiaryMixedReformList.stream()
//                .collect(Collectors.toMap(SubsidiaryMixedReform::getMixedEnterpriseId, subsidiaryMixedReform -> subsidiaryMixedReform));
//        //传输过来的单据数据
//        List<SubsidiaryMixedReform> transferReformList = subsidiaryMixedReformService.list(Wrappers.<SubsidiaryMixedReform>query()
//                .lambda().eq(SubsidiaryMixedReform::getDataSource, tokenUserId)
//                .eq(SubsidiaryMixedReform::getFormType, FormTypeConstant.QG_SUBSIDIARY_CHANGE_FORM));
//        Map<String, SubsidiaryMixedReform> transferReformMap = transferReformList.stream()
//                .collect(Collectors.toMap(SubsidiaryMixedReform::getDataSourceId, subsidiaryMixedReform -> subsidiaryMixedReform));
//        List<SubsidiaryMixedReform> noApprovalList = subsidiaryMixedReformService.list(Wrappers.<SubsidiaryMixedReform>query()
//                .lambda().ne(SubsidiaryMixedReform::getStatus, FormStatusConstant.FINISH)
//                .eq(SubsidiaryMixedReform::getFormType, FormTypeConstant.QG_SUBSIDIARY_CHANGE_FORM)
//                .in(SubsidiaryMixedReform::getMixedEnterpriseId, propertyIdList));
//        Map<String, SubsidiaryMixedReform> noApprovalMap = noApprovalList.stream()
//                .collect(Collectors.toMap(SubsidiaryMixedReform::getMixedEnterpriseId, subsidiaryMixedReform -> subsidiaryMixedReform));
//
//        List<String> messages = new ArrayList<>();
//        for (SubsidiaryMixedReformVO subsidiaryMixedReformVO : subsidiaryMixedReformVOList){
//            if (!childPropertyMap.containsKey(subsidiaryMixedReformVO.getAicOrgCode())){
//                messages.add("aicOrgCode = " + subsidiaryMixedReformVO.getAicOrgCode() + "，产权未登记");
//                continue;
//            }
//
//            PropertyBasics propertyBasics = childPropertyMap.get(subsidiaryMixedReformVO.getAicOrgCode());
//            String propertyId = propertyBasics.getId();
//            if(transferReformMap.containsKey(subsidiaryMixedReformVO.getDataSourceId())){
//                SubsidiaryMixedReform oldTransferReform = transferReformMap.get(subsidiaryMixedReformVO.getDataSourceId());
//                if (oldTransferReform.getStatus() != UNREVIEWED && oldTransferReform.getStatus() != REJECT && oldTransferReform.getStatus() != STASH){
//                    messages.add("aicOrgCode = " + subsidiaryMixedReformVO.getAicOrgCode()
//                            + ", dataSourceId = " + subsidiaryMixedReformVO.getDataSourceId() + "，再审批流程中或已审核");
//                    continue;
//                }
//                subsidiaryMixedReformVO.setId(oldTransferReform.getId());
//                subsidiaryMixedReformVO.setInitialId(oldTransferReform.getInitialId());
//                subsidiaryMixedReformVO.setLastVersionId(oldTransferReform.getLastVersionId());
//                subsidiaryMixedReformVO.setVersion(oldTransferReform.getVersion());
//            }else {
//                if (subsidiaryMixedReformMap.containsKey(propertyId)){
//                    SubsidiaryMixedReform subsidiaryMixedReform = subsidiaryMixedReformMap.get(propertyId);
//                    subsidiaryMixedReformVO.setInitialId(subsidiaryMixedReform.getInitialId());
//                    subsidiaryMixedReformVO.setLastVersionId(subsidiaryMixedReform.getId());
//                    subsidiaryMixedReformVO.setVersion(subsidiaryMixedReform.getVersion() + 1);
//                }else {
//                    if (noApprovalMap.containsKey(noApprovalMap)){
//                        SubsidiaryMixedReform oldTransferReform = noApprovalMap.get(propertyId);
//                        if (!String.valueOf(FormStatusConstant.UNREVIEWED).equals(oldTransferReform.getStatus())
//                                && !String.valueOf(FormStatusConstant.REJECT).equals(oldTransferReform.getStatus())){
//                            messages.add("aicOrgCode = " + subsidiaryMixedReformVO.getAicOrgCode()
//                                    + ", dataSourceId = " + subsidiaryMixedReformVO.getDataSourceId() + "，再审批流程中或已审核");
//                            continue;
//                        }
//                        subsidiaryMixedReformVO.setId(oldTransferReform.getId());
//                        subsidiaryMixedReformVO.setInitialId(oldTransferReform.getInitialId());
//                        subsidiaryMixedReformVO.setLastVersionId(oldTransferReform.getLastVersionId());
//                        subsidiaryMixedReformVO.setVersion(oldTransferReform.getVersion());
//                    }else {
//                        messages.add("aicOrgCode = " + subsidiaryMixedReformVO.getAicOrgCode()
//                                + ", dataSourceId = " + subsidiaryMixedReformVO.getDataSourceId() + "，不能进行混改变更");
//                        continue;
//                    }
//                }
//            }
//
//            subsidiaryMixedReformVO.setDataSource(tokenUserId);
//            subsidiaryMixedReformVO.setMixedEnterpriseId(propertyId);
//            subsidiaryMixedReformVO.setUnitRankId(propertyBasics.getOrgGradation());
//            subsidiaryMixedReformVO.setMajorIndustryId(propertyBasics.getMajorIndustries());
//            subsidiaryMixedReformVO.setAffiliatedOrgFullName(propertyBasics.getAffiliatedOrgFullName());
//            subsidiaryMixedReformVO.setFunctionalCategoryId(propertyBasics.getFunctionalCategoryName());
//            subsidiaryMixedReformVO.setMixedCategoryId(propertyBasics.getOrgCategory());
//            subsidiaryMixedReformVO.setStateFundedRelation(propertyBasics.getStateFundedRelation());
//            subsidiaryMixedReformVO.setRegisteredCapital(BigDecimalUtil.toBigdecimal(propertyBasics.getRegCapital()));
//        }
//
//        if (CollectionUtil.isNotEmpty(messages)){
//            return messages.stream().collect(Collectors.joining(StringPool.COMMA));
//        }
//        return null;
//    }
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean saveOutList(List<SubsidiaryMixedReformVO> subsidiaryMixedReformVOList) {
//        List<String> submitIds = new ArrayList<>();
//        for (SubsidiaryMixedReformVO subsidiaryMixedReformVO : subsidiaryMixedReformVOList){
//            subsidiaryMixedReformVO.setFormType(String.valueOf(FormTypeConstant.QG_SUBSIDIARY_OUT_FORM));
//            subsidiaryMixedReformVO.setStatus(FormStatusConstant.UNREVIEWED);
//            subsidiaryMixedReformVO.setOutType(2);
//            if (subsidiaryMixedReformVO.getId() == null){
//                subsidiaryMixedReformVO.setCode(formCodeService.getCode(FormTypeConstant.QG_SUBSIDIARY_OUT_FORM));
//            }
//            SubsidiaryMixedReform subsidiaryMixedReform = subsidiaryMixedReformWrapper.voToEntity(subsidiaryMixedReformVO);
//            subsidiaryMixedReformOutService.saveOrUpdate(subsidiaryMixedReform);
//            submitIds.add(String.valueOf(subsidiaryMixedReform.getId()));
//            mixedOwnershipStructureService.remove(Wrappers.<MixedOwnershipStructure>query()
//                    .lambda().eq(MixedOwnershipStructure::getMixedReformId, subsidiaryMixedReform.getId()));
//            if (CollectionUtil.isNotEmpty(subsidiaryMixedReform.getMixedOwnershipStructures())){
//                for (MixedOwnershipStructure mixedOwnershipStructure : subsidiaryMixedReform.getMixedOwnershipStructures()){
//                    mixedOwnershipStructure.setMixedReformId(subsidiaryMixedReform.getId());
//                }
//                mixedOwnershipStructureService.saveList(subsidiaryMixedReform.getMixedOwnershipStructures());
//            }
//        }
//        transferFlowService.submit(submitIds, FormTypeConstant.QG_SUBSIDIARY_OUT_FORM);
//        return true;
//    }
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean saveFile(List<MultipartFile> files, List<ReformTransferFileDTO> reformTransferFileDTOS) {
//        if (CollectionUtil.isEmpty(reformTransferFileDTOS)){
//            return true;
//        }
//        String tokenUserId = TokenUtil.getTokenUserId();
//        List<PageData> fileInfoList = FilesUtil.upFiles(files);
//        Map<String, PageData> fileMap = fileInfoList.stream().collect(Collectors.toMap(p -> p.getString("md5"), p -> p, (p1, p2) -> p1));
//        List<SubsidiaryMixedReform> existList = subsidiaryMixedReformService
//                .list(new LambdaQueryWrapper<SubsidiaryMixedReform>()
//                        .eq(SubsidiaryMixedReform::getDataSource, tokenUserId)
//                        .isNotNull(SubsidiaryMixedReform::getDataSourceId));
//        Map<String, Long> existIdMap =  existList.stream().collect(Collectors
//                .toMap(SubsidiaryMixedReform::getDataSourceId, SubsidiaryMixedReform::getId));
//
//        HashMap<String, String> extMap = FilesUtil.extMap();
//        List<HashMap> fileList = new ArrayList<>();
//        List<String> parentIds = new ArrayList<>();
//        for (ReformTransferFileDTO purchaseTransferFileDTO : reformTransferFileDTOS){
//            String parentId = String.valueOf(existIdMap.get(purchaseTransferFileDTO.getDataSourceId()));
//            parentIds.add(parentId);
//            setFilePageData(fileMap, extMap, purchaseTransferFileDTO.getFileMD5List(), fileList, parentId);
//        }
//
//        if (CollectionUtil.isNotEmpty(fileList)){
//            try {
//                fileDao.delByParentIds(parentIds);
//                fileDao.saveAll(fileList);
//            }catch (Exception e){
//                return false;
//            }
//        }
//        return true;
//    }
//
//    private void setFilePageData(Map<String, PageData> fileMap,  HashMap<String, String> extMap, List<String> md5List,
//                                 List<HashMap> fileList, String id){
//        for (String str : md5List){
//            if (fileMap.containsKey(str)){
//                PageData pd = fileMap.get(str);
//                PageData fileInfoMap = fileService.fileToFileInfo(pd);
//                fileInfoMap.put("parentId", id);
//                String ext = fileInfoMap.getString("ext");
//                if (extMap.containsKey(ext)){
//                    fileInfoMap.put("mime", extMap.get(ext));
//                }
//                fileList.add(fileInfoMap);
//            }
//        }
//    }
//}
